package com.theeviljames.pure;

import java.awt.Dimension;
import java.util.Arrays;

import com.theeviljames.exceptions.ComplexANNException;

public class OldComplexANNLayer {

	private Complex[][][] weights;
	private int[] topology;
	private IComplexMatrixOps c = ComplexMatrixOps.getComplexMatrixOps();
	
	public OldComplexANNLayer(int[] topology, double limit, boolean signed){
		this.topology = topology;
		weights = new Complex[topology.length-1][][];
		for(int i = 0; i < topology.length-1; i++){
			Complex[][] weightLayer = new Complex[topology[i]][topology[i+1]];
			for(int j = 0; j < topology[i]; j++){
				for(int k = 0; k < topology[i+1]; k++){
					weightLayer[j][k] = Complex.getRandom(limit, signed);
				}
			}
			weights[i] = weightLayer;
		}
	}
	
	public Complex[][] getOutputs(Complex[][] inputs) throws ComplexANNException{
		if(inputs[0].length!=topology[0])throw new ComplexANNException("The number of inputs must be equal to the number of input neurons");
		Complex[][] result = inputs;
		for(Complex[][] weightLayer:weights){
			result = c.times(weightLayer,result);
			result = c.sigmoid(result);
		}
		return result;
	}
	
/*	public Complex[][] rowToColumn(Complex[] vector){
		Complex[][] result = new Complex[vector.length][1];
		for(int i = 0; i < vector.length; i++){
			result[i][0] = vector[i];
		}
		return result;
	}
	
	public Complex[] columnToRow(Complex[][] matrix){
		Complex[] result = new Complex[matrix.length];
		for(int i = 0; i < matrix.length; i++){
			result[i] = matrix[i][0];
		}
		return result;
	}
*/	
	public void backprop(Complex[][] inputs, Complex[][] target) throws ComplexANNException{
		Complex[][] outputs = getOutputs(inputs);
		Complex[][] deltaError = c.minus(target, outputs);
		for(int i = topology.length-1; i >=0; i--){
			
		}
	}
	
	public void print(){
		System.out.println("Topology of the layer>\n\n" + Arrays.toString(topology) + "\n");
		for(int i = 0; i < weights.length; i++){
			System.out.println("Weights layer " + i + "\n");
			c.print(weights[i]);
			System.out.println("\n");
		}
	}
}
